import java.awt.Point;
import java.util.ArrayList;

/**
 * Class for the chess piece of a Queen
 * 
 * @author Jordan Beland
 *
 */
public class Queen extends Piece{

	/**
	 * default constructor for Queen object.
	 * 
	 * @author Jordan Beland
	 * 
	 * @param x
	 * @param y
	 */
	public Queen(int x, int y) {
		super(x, y);
		
	}
	
	 /**
	  * Overrides abstract method in class Piece.
	  * Calculates list of all possible moves of
	  * the Queen object at its current position.
	  * 
	  * @author Jordan Beland
	  * @return ArrayList<Point>
	  */
	@Override 
	public ArrayList<Point> possibleMoves() {
		int x = super.getX();
		int y = super.getY();
		ArrayList<Point> moves = new ArrayList<Point>(); //will contain coordinates of all possible moves
		//all possible moves in the horizontal right
		for(int i = x + 1; i < Board.SIZE; i++){
			moves.add(new Point(i, y));
		}
		//all possible moves in the horizontal left
		for(int i = x -1; i >= 0; i--){
			moves.add(new Point(i,y));
		}
		//all possible moves in the vertical down
		for(int j = y + 1; j < Board.SIZE; j++){
			moves.add(new Point(x,j));
		}
		//all possible moves in the vertical up
		for(int j = y -1; j >= 0; j--){
			moves.add(new Point(x,j));
		}
		//all possible moves in the down positive diagonal
		for(int j = y + 1, i = x+1 ; j < Board.SIZE && i < Board.SIZE ; j++, i++){
			moves.add(new Point(i,j));
		}
		//all possible moves in the up positive diagonal
		for(int j = y - 1, i = x+1 ; j >= 0 && i < Board.SIZE ; j--, i++){
			moves.add(new Point(i,j));
		}
		//all possible moves in the up negative diagonal
		for(int j = y - 1, i = x-1 ; j >= 0 && i >= 0 ; j--, i--){
			moves.add(new Point(i,j));
		}
		//all possible moves in the down negative diagonal
		for(int j = y + 1, i = x-1 ; j < Board.SIZE && i >= 0 ; j++, i--){
			moves.add(new Point(i,j));
		}
		
		return moves;
	}

}
